CSEG8003 Course home Portal
UPES · School of Computer Science
CSEG8003 — Modelling and Simulation · L-T-P-C 2-0-1-3
Unit I
Simulation Basics
7 lecture hours · Theory notes · Dr. Mohsin Furkh Dar
CO1 Stepped & event time Discrete vs continuous Numerical error Stochastic models Standards & ethics
How to use these notes

Every topic is written in three layers, and you should read and revise in the same order:

  1. Definition box — the exact sentence to write first in the examination.
  2. Explanation in plain language — so that the idea actually makes sense, not just the words.
  3. Numbered points, tables and examples — this is where the marks are. Examiners award marks for points, not for paragraphs.

Boxes marked Exam tip tell you what is usually asked. Boxes marked Common mistake tell you what loses marks. Section 11 at the end lists practice questions grouped by mark weight.

This unit builds the vocabulary and the mental model for the whole course. Everything that follows — agent-based models in Unit II, parallel simulation in Unit III, statistics in Unit IV, and result analysis in Unit V — assumes that you can answer three questions about any simulation you meet: how does its clock advance, what kind of state does it carry, and how much of its output do we believe.

1. Systems, Models and Simulation

Definition — System, Model, Simulation

A system is a collection of interacting entities, with state, that we wish to study for some purpose.

A model is a simplified, purposeful representation of a system that preserves the features relevant to a stated question and deliberately discards the rest.

Simulation is the execution of a model over time on a computer in order to observe how the modelled system behaves, especially when analytical solution is impossible, too expensive, or too risky to obtain from the real system.

The order of those three words matters. We never simulate a system directly; we simulate a model of it. Every claim a simulation makes is therefore a claim about the model, and it transfers to the real world only as far as the model is valid. This single sentence is the reason validation (Unit V) exists as a topic at all.

1.1 Why simulate at all?

  1. The system does not exist yet. A new airport terminal, a new cache hierarchy, a new epidemic-control policy — you cannot measure what is not built.
  2. Experimenting on the real system is unsafe, unethical or illegal. You may not deliberately overload a live power grid or infect a population to test a policy.
  3. The analytical model is intractable. Queueing theory gives closed forms for a handful of idealised cases; real networks with priorities, blocking and correlated arrivals have none.
  4. Real experiments are too slow or too fast. Galaxy formation takes 109 years; a transistor switch takes 10−12 s. Simulated time can be compressed or dilated at will.
  5. We need many repetitions. Rare-event risk (a once-in-200-year flood) can be estimated by running the model ten million times.
  6. We need controllability and repeatability. A simulation can be re-run with exactly one parameter changed — something the real world never permits.

1.2 Classification of models

Table 1.1 — The standard model taxonomy, with a computing example for each.
Axis Types Meaning and example
Nature Physical vs. mathematical A wind-tunnel scale model vs. a set of equations. This course is entirely about mathematical (and hence computational) models.
Time Static vs. dynamic Static: a Monte Carlo estimate of π, no clock. Dynamic: a queue at a router evolving over time.
Randomness Deterministic vs. stochastic Deterministic: same input → same output, always. Stochastic: contains random variates, so output is itself a random variable and needs replication.
State change Discrete vs. continuous Discrete: number of jobs in a queue jumps by ±1. Continuous: tank level h(t) varies smoothly. See Section 3.
Clock Time-stepped vs. event-driven Fixed Δt advance vs. jump-to-next-event advance. See Section 2.
Space Lumped vs. distributed One temperature for a whole room vs. a temperature field T(x, y, t) solved on a mesh.
Common mistake

Students routinely mix up discrete/continuous (a property of the state variables) with time-stepped/event-driven (a property of the clock mechanism). They are independent axes. A continuous model is almost always time-stepped, but a discrete-state model may be either. Write the two definitions apart and the marks are safe.

1.3 The simulation study life cycle

A simulation study is a research process, not a programming exercise. The standard sequence (Banks et al.) is:

  1. Problem formulation and objectives — write down the question the model must answer.
  2. Conceptual model building — entities, state, events, assumptions, level of detail.
  3. Data collection — arrival rates, service times, failure rates; fit distributions (Unit IV).
  4. Model translation — implement in a language or package.
  5. Verification — “Did I build the model right?” (code is faithful to the conceptual model).
  6. Validation — “Did I build the right model?” (model is faithful to reality). Covered fully in Unit V.
  7. Experimental design — run length, warm-up period, number of replications, scenarios.
  8. Production runs and statistical analysis of output.
  9. Documentation, reporting and implementation of the recommendation.
Exam tip

“Distinguish verification from validation” is a guaranteed short question. The one-line answer: verification checks the model against its specification; validation checks the model against reality. Then give one example of each.

2. Handling Stepped and Event-Based Time

A dynamic simulation needs a simulation clock: a variable holding the current value of simulated time, which is entirely separate from wall-clock time. There are exactly two ways to advance it.

2.1 Time-stepped (fixed-increment) simulation

Definition — Time-stepped simulation

In a time-stepped (fixed-increment, synchronous) simulation the clock advances by a constant step Δt, and at each tick every entity in the model is updated to reflect what happened during the interval [t, tt ).

The main loop is trivially simple, which is exactly why it is used everywhere in physics, graphics and games:

t = 0
while t < T_end:
    for each entity e:            # order matters; see caution below
        e.update(dt)
    record_statistics(t)
    t = t + dt

Choosing Δt is the whole art. Too large and events are missed or the numerical integration becomes unstable; too small and the run takes forever, most ticks doing nothing. A workable rule is Δt ≤ one-tenth of the fastest time constant in the system.

Common mistake — the update-order trap

If entities are updated in place, in a loop, entity 5 sees entity 1's new state and entity 9's old state within the same tick. This asymmetry is a bug in most models (notably cellular automata, Unit II). The fix is double buffering: compute all new states from the old array, then swap. Always mention this when asked about pitfalls of time-stepped simulation.

2.2 Event-based (discrete-event) simulation

Definition — Discrete-event simulation (DES)

In an event-based or discrete-event simulation, state changes only at a countable set of instants called events. The clock jumps directly from the current event to the timestamp of the next event, so periods in which nothing happens consume no computation at all.

Three data structures define a DES engine:

  1. The simulation clock t.
  2. The state — queue lengths, server busy/idle flags, counters.
  3. The future event list (FEL) — a priority queue of (timestamp, event-type, entity) records ordered by timestamp.
schedule(first_arrival, t = 0)
while FEL not empty and t < T_end:
    (t, event) = FEL.pop_min()      # the clock JUMPS to t
    handle(event)                   # may change state and schedule new events
    accumulate_statistics()
Example — single-server queue (M/M/1) as a DES

Events: ARRIVAL and DEPARTURE.

  • On ARRIVAL: schedule the next arrival at t+Exp(λ). If the server is idle, mark it busy and schedule DEPARTURE at t+Exp(μ); otherwise increment the queue length.
  • On DEPARTURE: if the queue is non-empty, remove one customer and schedule the next DEPARTURE; else mark the server idle.

Between 09:00 and 09:17 nothing happens, so a DES does zero work in that interval, while a 1 ms time-stepped model would execute 1 020 000 empty ticks.

Ties and determinism

Two events with identical timestamps must be broken deterministically (by a priority field, or by insertion sequence number), otherwise the same seed gives different answers on different runs or machines — a reproducibility failure that is very hard to debug later.

2.3 Comparison and choice

Table 1.2 — Time-stepped versus event-based time advance.
Criterion Time-stepped Event-based
Clock advance Fixed Δt Variable; jumps to next event time
Cost driver Number of ticks × number of entities Number of events (independent of idle time)
Accuracy of timing Quantised to Δt; events inside a step are aliased Exact to floating-point precision
Core data structure Array / grid / state vector Priority queue (heap, calendar queue)
Implementation effort Low — a for-loop Higher — event scheduling discipline required
Parallelisation Straightforward: barrier per tick (Unit III) Hard: needs conservative or optimistic synchronisation (Unit III)
Best when State changes continuously and everywhere (fluids, fields, ODEs, games) Activity is sparse and bursty (queues, networks, logistics, hardware)
Exam tip

A very common 10-mark question: “Compare stepped and event-based time handling with an example.” Structure: two definitions → two pseudocode loops → the table above (six rows is plenty) → one worked example showing wasted ticks → one sentence on when a hybrid is used. That is a full-mark answer.

2.4 Mixed and adaptive time advance

Real engines often combine the two. A network simulator may integrate a physical-layer signal with a fixed step while handling packet arrivals as events; a game engine uses a fixed step for physics but an event queue for collisions and AI triggers. Adaptive time-stepping (Section 4.4) sits in between: the step shrinks where the solution changes fast and grows where it is smooth.

3. Discrete versus Continuous Modelling

Definition

In a discrete model the state variables change only at separated points in time, by finite jumps; the state space is typically countable (queue length, number of infected people, machine up/down).

In a continuous model the state variables change smoothly with time and are usually described by differential equations; the state space is a continuum (temperature, concentration, velocity, voltage).

3.1 The same system, modelled both ways

Population growth is the standard classroom pair, and is also Experiment 2 in your laboratory.

Continuous (logistic ODE):   dP/dt = r P (1 − P/K)
Discrete (logistic map):   Pn+1 = Pn + r Pn(1 − Pn /K)

These are not the same model. The continuous logistic equation always converges monotonically to the carrying capacity K. Its discrete counterpart, for growth rates above roughly r = 2, oscillates; above about 2.57 it becomes chaotic. Discretising a continuous model can therefore introduce behaviour that the original system does not have — a point worth one full paragraph in any answer on this topic.

3.2 Choosing between them

  1. Population size. With 20 machines, integrality matters (you cannot have 3.7 machines) → discrete. With 109 molecules, the fluid limit is excellent → continuous.
  2. Question asked. If the answer is a mean flow rate, continuous suffices. If the answer is “what fraction of customers wait more than 5 minutes”, individual identity is needed → discrete.
  3. Availability of data. Rate constants favour ODEs; logged timestamps favour discrete-event models.
  4. Cost. Continuous models scale with the number of state variables; discrete models scale with the number of entities and events.
Table 1.3 — Discrete versus continuous modelling at a glance.
Aspect Discrete Continuous
State change Jumps at event instants Smooth, at all instants
Mathematics Difference equations, Markov chains, queueing ODEs, PDEs, SDEs
Typical solver Event list / state machine Euler, Runge–Kutta, finite difference/element
Individuality Entities are tracked individually Only aggregate quantities exist
Error concern Statistical (sampling) error Truncation and round-off error
Examples Bank queue, packet network, assembly line, SIR on a contact network Heat conduction, orbital motion, chemical kinetics, compartmental SIR

3.3 Combined (continuous–discrete) simulation

Many engineering systems are genuinely both. A chemical batch reactor has continuous temperature and concentration, but a discrete valve that opens when concentration crosses a threshold. Such models are called combined or hybrid (Section 7). The technical difficulty is state-event detection: the exact instant of threshold crossing lies inside an integration step, so the solver must detect the sign change of a zero-crossing function and then bisect or interpolate back to locate the crossing time before firing the discrete event.

4. Numerical Techniques

Continuous models must be discretised before a computer can execute them. The numerical method chosen determines the accuracy, the stability and much of the cost of the whole simulation.

4.1 Numerical integration of ODEs

Given the initial value problem dy/dt = f(t, y) with y(t0) = y0, and step h:

Explicit (forward) Euler:   yn+1 = yn + h f(tn, yn ) O(h) global error
Implicit (backward) Euler:   yn+1 = yn + h f(tn+1, yn +1) solve at each step
Trapezoidal / Heun:   yn+1 = yn + (h/2)[fn + fn+1] O(h2)
Classical RK4:   yn+1 = yn + (h/6)(k1 + 2k2 + 2k3 + k4) O(h4)

with k1 = f(tn, y n), k2 = f(tn + h/2, yn + hk1/2), k3 = f(tn + h/2, yn + hk2/2), k4 = f(tn + h, yn + hk3).

Example — why order matters

Integrate dy/dt = −y, y(0) = 1 to t = 1 (exact value e−1 = 0.367879). With h = 0.1, explicit Euler gives 0.910 = 0.348678 (error 1.9×10−2); RK4 with the same step gives 0.367879 (error < 10−7). Halving h halves Euler's error but divides RK4's by sixteen — that is what “fourth order” means in practice.

4.2 Stability and stiffness

Accuracy is not the only concern; a method can be accurate in principle and still explode. For the test equation dy/dt = λy with λ < 0, explicit Euler is stable only if |1 + hλ| < 1, that is h < 2/|λ|. Backward Euler is stable for every h > 0 (it is A-stable), which is why implicit methods are used for stiff systems — systems containing time constants that differ by many orders of magnitude, where an explicit method would be forced down to the smallest constant even though the interesting behaviour is slow.

4.3 Other numerical machinery you will meet

4.4 Adaptive step control

Embedded pairs such as Runge–Kutta–Fehlberg (RKF45) compute two estimates of different order at each step; their difference estimates the local error, and the step is accepted, rejected or resized to keep that error near a tolerance. This gives accuracy where the solution is fast-changing and speed where it is not.

Common mistake

“RK4 is always better than Euler” is false as stated. RK4 costs four function evaluations per step. If f is expensive and the tolerance is loose, Euler with a smaller step can win; and for a stiff problem, neither explicit method works — you need an implicit one. Answer such questions in terms of accuracy per unit cost and stability, not in terms of a ranking.

5. Sources and Propagation of Error

Definition — Error

Absolute error = |computed − true|. Relative error = |computed − true| / |true|. In simulation the “true” value may itself be unknown, so error is estimated by refinement studies, by analytical special cases, or by statistical confidence intervals.

5.1 The five sources of error

  1. Modelling error. The gap between reality and the conceptual model — assumptions of independence, neglected friction, homogeneous mixing. Usually the largest error, and the one no numerical refinement can reduce.
  2. Data / input error. Measurement noise, wrongly fitted distributions, outdated parameters.
  3. Truncation (discretisation) error. From replacing a limit with a finite quantity: a derivative by a difference quotient, an infinite series by a partial sum, continuous time by a step h.
  4. Round-off error. From finite floating-point precision (IEEE 754 double: about 16 significant decimal digits, machine epsilon ≈ 2.2×10−16).
  5. Statistical (sampling) error. In stochastic models, from using a finite number of replications; decreases only as 1/√n (Unit IV).

Truncation error decreases as the step h shrinks, while accumulated round-off error increases because more steps are taken. Their sum has a minimum: there is an optimal h, and going below it makes the answer worse. Sketching this U-shaped curve earns marks.

5.2 Propagation of error

Errors do not stay where they are born. For a smooth function y = f(x 1, …, xn) with small independent input errors, first-order propagation gives:

Δy ≈ ∑i |∂f/∂x i| Δxi   (worst case),    σy2 ≈ ∑i (∂f/∂xi)2σi 2   (statistical)

The partial derivatives are exactly the sensitivity coefficients of Unit IV, so error propagation and sensitivity analysis are two views of the same computation.

Conditioning and stability

5.3 Practical rules for controlling error

  1. Never test floating-point numbers for equality; compare against a tolerance.
  2. Avoid subtracting nearly equal numbers (catastrophic cancellation); rearrange the formula algebraically. The classic fix is the stable quadratic-root formula.
  3. Sum many small numbers in ascending order, or use Kahan compensated summation.
  4. Do a grid-refinement (convergence) study: halve h, and confirm that the answer changes by the amount the method's order predicts.
  5. Report a confidence interval, never a bare number, for stochastic output.
  6. Keep a fixed random seed for debugging and vary it for production replications.

6. Stochastic Modelling and Simulation

Definition — Stochastic simulation

A stochastic simulation is one in which at least one input is a random variable, so that each run produces a different sample path and the output is itself a random variable. A single run is therefore one observation, never an answer.

6.1 Why randomness belongs in the model

Uncertainty is not an imperfection to be averaged away at the input. Because most performance measures are non-linear, the mean of the outputs is not the output of the mean — the “flaw of averages”. A road designed for the average traffic load is congested half the time; a server sized for mean demand has unbounded queues at the peak.

6.2 The machinery (previewed here, detailed in Unit IV)

  1. Pseudo-random number generators (PRNGs) produce a deterministic stream u1, u2, … that behaves statistically like independent Uniform(0,1) draws. Modern choices: Mersenne Twister, PCG, xoshiro256++. Requirements: long period, good equidistribution, speed, and reproducibility from a seed.
  2. Random variate generation converts uniforms into the required distribution — inverse transform, acceptance–rejection, convolution, composition.
  3. Replication: run n independent repetitions with different substreams and report the mean with a confidence interval.
  4. Variance reduction: common random numbers, antithetic variates, control variates, importance sampling — techniques that buy accuracy without buying CPU time.
Half-width of the 95% confidence interval:   h = tn−1, 0.975 · s/√n

The 1/√n law is worth memorising: to halve the confidence interval you must quadruple the number of replications. This is the single most important economic fact about stochastic simulation, and it is the reason Unit III (parallelism) and variance reduction both matter.

6.3 Common stochastic model families

Exam tip

If a question asks “why must a stochastic simulation be replicated?”, the marks are for: (i) output is a random variable; (ii) one run gives one sample, with unknown variance; (iii) confidence interval formula; (iv) 1/√n convergence; (v) different seeds / independent substreams must be used.

7. Optimization in Simulation Models

Definition — Simulation optimization

Simulation optimization is the problem of finding the input configuration x* that optimises the expected performance of a simulation model, minxX E[g(x, ξ)], where the objective can only be estimated by running the (noisy, expensive, derivative-free) model.

Three properties make this hard and distinguish it from ordinary mathematical programming:

  1. The objective is a black box — no formula, hence no gradient.
  2. Each evaluation is noisy — two evaluations of the same x differ.
  3. Each evaluation is expensive — minutes to hours, so the budget is a few hundred evaluations, not millions.

7.1 Families of methods

Table 1.4 — Approaches to optimising a simulation model.
Family Representative methods When to use
Ranking & selection Two-stage Rinott, KN procedure, OCBA Few discrete alternatives (say ≤ 100); allocate replications to find the best with a guaranteed probability of correct selection.
Gradient-based Finite differences, SPSA, infinitesimal perturbation analysis, likelihood ratio Continuous parameters, smooth response; SPSA needs only 2 evaluations per iteration regardless of dimension.
Metaheuristics Genetic algorithms, simulated annealing, tabu search, particle swarm, ant colony Large, rugged, combinatorial search spaces; no guarantee of optimality but good solutions in practice. This is what commercial packages (OptQuest) use.
Metamodel / surrogate Response surface methodology, kriging, Bayesian optimization Very expensive simulations; fit a cheap surrogate to a designed set of runs and optimise that, adding new runs where the surrogate is uncertain.
Sample average approximation Fix the seed, optimise the deterministic surrogate problem When the model can be re-expressed as a mathematical program for a fixed sample.

7.2 Design of experiments as the cheap alternative

Before optimising, screen. A 2k factorial or fractional-factorial design identifies which of k factors actually matter, at a fraction of the cost of a full grid search. Latin hypercube sampling covers a continuous space evenly with few runs. Optimisation is then carried out only over the two or three factors that survived screening.

Common mistake

Comparing two designs using one replication each and declaring the smaller number the winner. With noisy output the difference may be pure sampling variation. Always compare with a paired confidence interval on the difference, ideally using common random numbers so that both designs face the same random events.

8. Hybrid and Multi-Scale Modelling

Definition

A hybrid model combines two or more modelling paradigms — for example continuous (system dynamics), discrete-event and agent-based — within a single executable model, so that each part of the system is represented in the formalism that suits it best.

A multi-scale model couples sub-models that operate at different characteristic length or time scales, passing information between the scales.

8.1 Why hybridise

  1. No single paradigm fits a whole real system: a hospital has continuous disease progression, discrete patient flow through resources, and autonomous decision-making staff.
  2. Detail is needed only in part of the domain; the rest can run in a cheaper representation.
  3. Legacy models already exist in different formalisms and must be federated rather than rewritten (see HLA, Section 9).

8.2 Coupling patterns

8.3 The hard problems in coupling

  1. Time-scale mismatch. One model steps in nanoseconds, the other in hours; the coupling interval and the sub-cycling scheme must be chosen explicitly.
  2. Unit, semantic and representation mismatch. Converting a continuous concentration into an integer number of agents (and back) is not neutral — rounding systematically biases small populations.
  3. Consistency and conservation. Mass, energy or entity count must not be created or destroyed at the interface.
  4. Stability of the coupled system. Two individually stable solvers can be unstable when coupled explicitly.
  5. Compounded validation. Each sub-model and every interface must be validated; the credibility of the whole is bounded by the weakest link.
Example — a hybrid epidemic model

National-level transmission is modelled with continuous SIR compartments (fast, aggregate). Within a chosen city, individuals are modelled as agents on a contact network (Unit II) to test contact-tracing policies. The compartment model exports an imported-case rate into the city model; the city model exports a measured effective reproduction number back. Both run on the same coupling interval of one day.

9. Modelling and Simulation Standards

Standards exist so that models built by different teams, in different tools, at different times can be trusted, reused and connected. They fall into three groups.

9.1 Interoperability standards

9.2 Process and credibility standards

9.3 Model representation and reporting standards

Exam tip

For “write short notes on M&S standards”, do not list twenty acronyms. Give the three categories above, then two or three examples in each with one line of purpose, and close with why standards matter: interoperability, reuse, credibility, reproducibility and procurement.

10. Simulation Software and Tools

This course is about building simulation environments, not merely operating a package — so you should be able to justify the choice between writing a simulator and buying one.

Table 1.5 — The simulation software landscape.
Category Examples Character
General-purpose languages + libraries Python (SimPy, NumPy/SciPy, Mesa, NetworkX, salabim), C++ (with a hand-written event list), Julia (DifferentialEquations.jl, Agents.jl), R Maximum flexibility and transparency; you own the algorithms. Chosen for research and for this course's laboratory.
Discrete-event packages Arena, Simul8, FlexSim, AnyLogic, ExtendSim, GPSS Drag-and-drop process blocks, animation, built-in statistics and optimiser. Fast for standard queueing/manufacturing studies.
Continuous / equation-based MATLAB & Simulink, Modelica/OpenModelica, Dymola, Scilab/Xcos Block diagrams and acausal equations; strong ODE/DAE solvers and control design.
Agent-based / complex systems NetLogo, Repast, MASON, GAMA, Mesa Grids, networks, spatial agents, visual inspection of emergent behaviour (Unit II).
Domain-specific ns-3 / OMNeT++ (networks), gem5 (computer architecture), SUMO / VISSIM (traffic), OpenFOAM / ANSYS (CFD), LAMMPS / GROMACS (molecular), PowerFactory / PSS®E (power) Validated domain physics and model libraries; the sensible choice when your problem is already in a well-served domain.
Parallel / HPC frameworks MPI, OpenMP, CUDA, ROSS, Charm++, Dask, Ray The substrate for Unit III; execution machinery rather than modelling formalism.
Analysis and visualisation Matplotlib, Plotly/Dash, ParaView, VisIt, Tableau, D3.js Unit V: turning result files into defensible figures and interactive interfaces.

10.1 Criteria for selecting a tool

  1. Does its world view (process interaction, event scheduling, activity scanning, agent-based, equation-based) match your model?
  2. Statistical support: distribution fitting, replication control, confidence intervals, variance reduction.
  3. Scalability and parallel execution; ability to run headless in batch on a cluster.
  4. Extensibility: can you insert custom code, or are you trapped inside the GUI?
  5. Verification and debugging support: tracing, step-through, event logs, seed control.
  6. Interoperability: HLA/FMI support, standard input and output formats.
  7. Licence cost, licence terms, and the size of the user community; longevity of the vendor.
  8. Reproducibility: version pinning, scripted (not click-driven) experiments.
Example — a ten-line discrete-event model in SimPy
import simpy, random

def customer(env, name, server):
    with server.request() as req:          # join the queue
        yield req                          # wait for the server
        yield env.timeout(random.expovariate(1/3.0))   # service

def source(env, server):
    i = 0
    while True:
        yield env.timeout(random.expovariate(1/4.0))   # inter-arrival
        env.process(customer(env, i, server)); i += 1

env = simpy.Environment()
server = simpy.Resource(env, capacity=1)
env.process(source(env, server))
env.run(until=1000)

Notice that the future event list, the clock and the ordering are all provided by the framework; what you write is only the process description. That is the process-interaction world view.

11. Ethical and Practical Considerations

Simulation results are used to justify decisions that affect money, safety and lives. The ethical obligations are therefore professional obligations, not optional extras.

11.1 Ethical issues

  1. Honest reporting of assumptions and limitations. Every model is wrong in stated ways; concealing the assumptions makes a result rhetorical rather than scientific.
  2. Fitness for purpose. A model validated for one operating range must not be quoted outside it. Accreditation exists precisely to record the domain of validity.
  3. Avoiding advocacy modelling. Choosing parameters, scenarios or output measures that produce a pre-determined conclusion is falsification, however subtly done.
  4. Transparency and reproducibility. Publish the model, the parameters, the seeds and the version. An unpublishable model cannot be checked and should not be believed.
  5. Data privacy and consent. Agent-based models of health, mobility or social behaviour are often built from personal data; anonymisation, aggregation, consent and applicable data-protection law all apply.
  6. Bias and fairness. A model calibrated on data from one group and applied to another can systematically disadvantage people — in policing, credit, healthcare or infrastructure planning.
  7. Communication to non-experts. Presenting a stochastic projection as a prediction, or hiding uncertainty behind a single smooth curve, misleads the decision maker even when every number is correct.
  8. Dual use and misuse. Models of infrastructure, epidemics or weapons can be used to attack as well as to protect; access and publication need judgement.
  9. Professional codes. The ACM/IEEE Software Engineering Code of Ethics and the SCS/SISO codes for simulationists apply to this work directly.

11.2 Practical considerations

  1. Data quality and availability usually limits accuracy far more than the algorithm does. Budget most of the project time for data.
  2. The right level of detail. Detail costs data, runtime and credibility. A model should be as simple as the question permits — and no simpler.
  3. Computational budget. Run length, warm-up, replications and scenario count multiply; plan them before running anything.
  4. Software engineering discipline. Version control, unit tests on the event logic, regression tests on known analytical cases, and a recorded seed for every reported figure.
  5. Documentation. The model description (ODD or equivalent) must let a competent stranger reimplement the model.
  6. Stakeholder involvement. A model that domain experts have not reviewed will not be trusted, and usually should not be.
Exam tip

“All models are wrong, but some are useful” (George Box) is the standard opening quotation for an ethics answer — but do not stop there. Follow it with the point that usefulness is relative to a stated purpose, and that stating the purpose, the assumptions and the uncertainty is the modeller's ethical duty.

12. Unit Summary

12.1 Key terms

System · model · simulation · simulation clock · time-stepped · discrete-event · future event list · state event · truncation error · round-off error · stiffness · A-stability · PRNG · replication · confidence interval · variance reduction · metamodel · ranking and selection · federation / federate / RTI · DEVS · VV&A · ODD protocol.

12.2 Practice questions

Short answer (2–3 marks each)

  1. Define simulation. State two situations in which simulation is preferred to analytical solution.
  2. Differentiate between verification and validation with one example of each.
  3. What is a future event list and why must it be a priority queue?
  4. Distinguish truncation error from round-off error.
  5. Why does halving the confidence-interval width require four times as many replications?
  6. What is a stiff system, and which class of integrators is used for it?
  7. State any three purposes served by simulation standards.

Medium answer (5 marks each)

  1. Write the algorithm for a time-stepped simulation and for an event-driven simulation, and state two advantages of each.
  2. Explain the sources of error in a simulation study and sketch how total error varies with the step size h.
  3. Explain, with the M/M/1 queue as an example, how a discrete-event simulation advances time and accumulates statistics.
  4. Discuss the difficulties specific to simulation optimization and name one method from each of three families.
  5. What is multi-scale modelling? Describe two coupling patterns and two problems that arise at the interface.

Long answer (10 marks each)

  1. Compare stepped and event-based time handling in simulations under at least six criteria, with pseudocode and one worked example showing the cost difference.
  2. Compare discrete and continuous modelling. Illustrate with a population-growth model formulated both ways, and explain how the discretisation can introduce behaviour absent from the continuous model.
  3. Describe the numerical techniques used in continuous simulation. Derive or state Euler and RK4, discuss order of accuracy, stability, stiffness and adaptive step control.
  4. Explain stochastic simulation end to end: pseudo-random generation, variate generation, replication, confidence intervals and variance reduction.
  5. Discuss the ethical and practical considerations in modelling and simulation, with examples of how each can be violated in practice.

12.3 Further reading

CSEG8003 Modelling and Simulation · Unit I student notes · Dr. Mohsin Furkh Dar · UPES